using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Login : System.Web.UI.Page
{
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (DataAccess.Authenticate(txtUserName.Text, txtPassword.Text))
        {
            Response.Redirect("~/Members/Stock.aspx");
        }
        else 
        {
            this.lblInfo.Text = "Invalid username or password!";
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {        
 
        lblInfo.Text = "";

        //if (!Page.IsPostBack)
        //{
        //    txtUserName.Attributes.Add("onclick", "Empty(this);");
        //    txtPassword.Attributes.Add("onclick", "Empty(this);");
        //}

        if (QueryStrings.Action == "logout")
        {
            Sessions.CurrentMember = new Member();
            lblInfo.Text = "";
        }

        if (!Sessions.CurrentMember.IsNull())
        {
            Response.Redirect("Members/Stock.aspx");
        }

        if (Sessions.GlobalMessage == Strings.Yetkisiz)
        {
            lblInfo.Text = Sessions.GlobalMessage;
        }
    }
}
